<template>
<div class="user-avator-dropdown">
    <Dropdown @on-click="handleClick">
		<Avatar :src="userAvator"/>
      <Icon :size="18" type="md-arrow-dropdown" style="color: #fff;"></Icon>
      <DropdownMenu slot="list">
        <DropdownItem name="my_info">我的资料</DropdownItem>
        <DropdownItem name="logout">退出登录</DropdownItem>
      </DropdownMenu>
    </Dropdown>
</div>
</template>

<script>
import Wcore from '@/libs/common';

export default {
  name: 'user_bar',
  props: {
    userAvator: {
      type: String,
      default: ''
    },
  },
  methods: {
    logout () {
		Wcore.setData(Wcore.prefix('token'),'');
		this.$router.push({name:'login'});
    },
    my_info () {
		this.$router.push({name:'my_info'});
    },
    handleClick (name) {
      switch (name) {
        case 'logout': this.logout()
          break
        case 'my_info': this.my_info()
          break
      }
    }
  }
}
</script>
<style scoped lang="less">
    @import './user_bar.less';
</style>